package com.xthh._sort;


import com.xthh._struct.HH_T_FolderSearch;

import java.util.Comparator;

public class HH_SortComparatorName implements Comparator {
    @Override
    public int compare(Object lhs, Object rhs) {
        HH_T_FolderSearch a = (HH_T_FolderSearch) lhs;
        HH_T_FolderSearch b = (HH_T_FolderSearch) rhs;

        if (a == null || b == null)
            return 0;

        String path_a = "";
        if (a.getPath() != null){
            String[] split = a.getPath().split("/");
            if (split != null && split.length > 0){
                path_a = split[split.length - 1];
            }
        }


        String path_b = "";
        if (b.getPath() != null){
            String[] split = b.getPath().split("/");
            if (split != null && split.length > 0){
                path_b = split[split.length - 1];
            }
        }

        return path_a.compareToIgnoreCase(path_b);


    }
}
